package com.geekhole.demo.app.shop;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import static com.geekhole.demo.app.TimeUtil.sleep;

@Service
public class ShopApplication {
    public Shop getById(Long id){
        sleep(20);
        Shop shop = createShop(id);
        return shop;
    }

    private Shop createShop(Long id) {
        Shop shop = new Shop();
        shop.setId(id);
        shop.setName("店铺-" + id);
        return shop;
    }

    public List<Shop> getByIds(List<Long> ids){
        sleep(50);
        return ids.stream()
                .map(this::createShop)
                .collect(Collectors.toList());
    }
}
